/**
 *
 */
package jp.seraph.jsmf.codec;

import org.apache.commons.lang.NullArgumentException;

import jp.seraph.jsade.model.AngleVelocityCalculator;
import jp.seraph.jsmf.motion.AbstractMotionElement;
import jp.seraph.jsmf.motion.MotionElement;
import jp.seraph.jspf.pose.DefaultPoseElement;
import jp.seraph.jspf.pose.Pose;
import jp.seraph.jspf.pose.PoseElement;
import jp.seraph.jspf.pose.PoseManager;

/**
 *
 *
 */
public class PoseNameLinkMotionElement extends AbstractMotionElement implements MotionElement {
    public PoseNameLinkMotionElement(PoseManager aManager, PoseNameLinkMotionElementData aElementData){
        super(aElementData.getName(), aElementData.getConditionElementName(), aElementData.getStartPercentage());
        if(aElementData == null)
            throw new NullArgumentException("aElementData");
        if(aManager == null)
            throw new NullArgumentException("aManager");

        mManager = aManager;
        mElementData = aElementData;
    }

    private PoseManager mManager;
    private PoseNameLinkMotionElementData mElementData;

    /**
     *
     * @see jp.seraph.jsmf.motion.MotionElement#getPoseElement()
     */
    public PoseElement getPoseElement() {
        Pose tPose = mManager.getPose(mElementData.getPoseName()).filter(mElementData.getIdentifiers());
        return new DefaultPoseElement(tPose, mElementData.getCalculator());
    }

    public Pose getPose(){
        return mManager.getPose(mElementData.getPoseName());
    }

    public String getPoseName(){
        return mElementData.getPoseName();
    }

    public AngleVelocityCalculator getCalculator(){
        return mElementData.getCalculator();
    }

    public PoseNameLinkMotionElementData getElementData(){
        return mElementData;
    }

    public PoseManager getPoseManager(){
        return mManager;
    }
}
